package main

import "fmt"

//结构体

type person struct {
	name   string
	age    int
	gender string
	hobby  []string
}

func main() {
	var p person
	//通过字段赋值
	p.name = "zhoulin"
	p.age = 9000
	p.gender = "男"
	p.hobby = []string{"篮球", "足球", "双色球"}
	fmt.Printf("p===%T \n", p)
	fmt.Println(p)
	//访问变量p的字段
	fmt.Println(p.name)
	fmt.Println(p.hobby[1])

	var p2 person
	p2.name = "lixiang"
	p2.age = 20
	fmt.Printf("p2===%T \n", p2)
	fmt.Println(p2)

	//匿名结构体，多用于临时场景
	var s struct {
		name string
		age  int
	}
	s.name = "zhaojinding"
	s.age = 20
	fmt.Printf("s===%T \n", s)
	fmt.Println(s)

}
